<template>
  <div>
    <!-- 头部导航 -->
    <van-nav-bar
      :title="comment.reply_count ? comment.reply_count + '条回复' : '暂无回复'"
    >
      <template #left>
        <van-icon name="cross" @click="$emit('showPost')"></van-icon>
      </template>
    </van-nav-bar>
    <div class="scroll-warp">
      <!-- 当前评论信息 -->
      <CommentItem :comment="comment" />
      <van-cell title="全部回复"></van-cell>
      <!-- 评论回复信息 -->
      <ArticleComment type="c" :source="comment.com_id" :list="list" />
    </div>
    <div class="post-warp">
      <van-button round @click="isShowReplyPost = true">评论</van-button>
    </div>
    <!-- 弹出层 -->
    <van-popup v-model="isShowReplyPost" position="bottom">
      <!-- 评论回复弹出层子组件 -->
      <ArticlePost
        :target="comment.com_id"
        :artId="$route.params.articleId"
        @onCommentPost="closePopup"
      />
    </van-popup>
  </div>
</template>

<script>
import CommentItem from '@/components/comment-item'
import ArticleComment from './article-comment.vue'
import ArticlePost from './article-post.vue'
export default {
  name: 'ReplyPost',
  components: {
    CommentItem,
    ArticleComment,
    ArticlePost
  },
  props: {
    comment: {
      type: Object,
      required: true
    }
  },
  data () {
    return {
      // 评论数据
      list: [],
      isShowReplyPost: false
    }
  },
  methods: {
    // 关闭弹层
    closePopup (e) {
      this.list.unshift(e)
      this.comment.reply_count++
      this.isShowReplyPost = false
    }
  }
}
</script>

<style scoped lang='less'>
/deep/.van-nav-bar {
  background-color: #3296fa;
  .van-nav-bar__title {
    color: #fff;
  }
  .van-icon {
    color: #fff !important;
  }
}
.scroll-warp {
  position: absolute;
  top: 92px;
  bottom: 102px;
  width: 100%;
  overflow-y: auto;
}
.post-warp {
  width: 100%;
  height: 100px;
  position: fixed;
  bottom: 0;
  border-top: 1px solid #ccc;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #3296fa;
  .van-button {
    width: 640px;
    height: 80px;
  }
}
</style>
